//
//  CustomCell.m
//  sinaTextDemo
//
//  Created by zc on 2414-2-24.
//  Copyright (c) 2014年 zc. All rights reserved.
//

#import "CustomCell.h"


@interface CustomCell ()

@property (strong,nonatomic)NSMutableDictionary *constraintDict;

@property (assign,nonatomic)CGFloat height;

@end


@implementation CustomCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}


-(NSLayoutConstraint *)constraintTarget:(UIView *)targetView attribute:(NSLayoutAttribute)targetViewAttibute relatedby:(NSLayoutRelation)relation toItem:(UIView *)sourceView attribute:(NSLayoutAttribute)viewAttibute multiplier:(CGFloat)multiplier constant:(CGFloat)constant{

    return [NSLayoutConstraint constraintWithItem:targetView attribute:targetViewAttibute relatedBy:relation toItem:sourceView attribute:viewAttibute multiplier:multiplier constant:constant];
    
}




-(void)createViews{
    
//    [self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
    
    self.sourceView = [[UIView alloc]init];
    [self addSubview:_sourceView];
    [self.sourceView setTranslatesAutoresizingMaskIntoConstraints:NO];
    
    
//    
//    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-2-[_sourceView(50)]-2-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_sourceView)]];
//    
//    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-2-[_sourceView(50)]-2-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_sourceView)]];
    
    
    //宽相等
    [self addConstraint:[self constraintTarget:self.sourceView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]];
    
    
    //高相等
    [self addConstraint:[self constraintTarget:self.sourceView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]];
    
    
    
    [self addConstraint:[self constraintTarget:self.sourceView attribute:NSLayoutAttributeCenterX relatedby:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
    
     [self addConstraint:[self constraintTarget:self.sourceView attribute:NSLayoutAttributeCenterY relatedby:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
    
    self.sourceView.backgroundColor = [UIColor clearColor];
    
    
//    NSLog(@"sourceView frame is %@",NSStringFromCGRect(_sourceView.bounds));
    
    
    
    
    //头像
    self.photoHeadImageView = [[UIImageView alloc]init];
    [_sourceView addSubview:self.photoHeadImageView];
    [self.photoHeadImageView setTranslatesAutoresizingMaskIntoConstraints:NO];

    //距左边10pix
    
    [_sourceView addConstraint:[self constraintTarget:_photoHeadImageView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_sourceView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10]];
    
    //上边5pix
    [_sourceView addConstraint:[self constraintTarget:_photoHeadImageView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:_sourceView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5]];
    
    //宽高
    [_sourceView addConstraint:[self constraintTarget:_photoHeadImageView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:50]];
    [_sourceView addConstraint:[self constraintTarget:_photoHeadImageView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:50]];
//    
    [_photoHeadImageView setBackgroundColor:[UIColor clearColor]];
    
    
    //用户昵称
    
    self.nameLabel = [[UILabel alloc]init];
    [self.nameLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
    [_sourceView addSubview:self.nameLabel];
    
    
    //距左边10pix
    
    [_sourceView addConstraint:[self constraintTarget:self.nameLabel attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:10]];
    
    //平行头像
    [_sourceView addConstraint:[self constraintTarget:self.nameLabel attribute:NSLayoutAttributeCenterY relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:-10]];
    
    self.nameLabel.backgroundColor = [UIColor clearColor];
    
    self.nameLabel.preferredMaxLayoutWidth = 250;
  
    self.nameLabel.numberOfLines = 0;
    
    self.nameLabel.text=@"用户昵称";
    
    
    
    //时间
    
    self.timeLabel = [[UILabel alloc]init];
    [self.timeLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
    [_sourceView addSubview:self.timeLabel];
    
    [_sourceView addConstraint:[self constraintTarget:self.timeLabel attribute:NSLayoutAttributeBaseline relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeBaseline multiplier:1.0 constant:0]];
    
    //在用户昵称下面
    [_sourceView addConstraint:[self constraintTarget:self.timeLabel attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_nameLabel attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
    self.timeLabel.backgroundColor = [UIColor clearColor];
    self.timeLabel.text = @"2014-02-24";
    
    
    //来源
    
    self.sourceLabel = [[UILabel alloc]init];
    [self.sourceLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.sourceView addSubview:self.sourceLabel];
    
    [_sourceView addConstraint:[self constraintTarget:self.sourceLabel attribute:NSLayoutAttributeCenterY relatedby:NSLayoutRelationEqual toItem:_timeLabel attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
    
    //在时间右面
    [_sourceView addConstraint:[self constraintTarget:self.sourceLabel attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_timeLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:20]];
    self.sourceLabel.backgroundColor = [UIColor clearColor];
    self.sourceLabel.text = @"来自iPhone5S";
    self.sourceLabel.font = [UIFont systemFontOfSize:12.0f];
    self.sourceLabel.preferredMaxLayoutWidth = 100;
    
    self.sourceLabel.numberOfLines = 0;

    
    
    
    
    
    
    self.textView = [[JSTwitterCoreTextView alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
    [self.textView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.sourceView addSubview:self.textView];
    
    
    
    
    //左对齐
    [self.sourceView addConstraint:[self constraintTarget:self.textView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];

    
    [self.sourceView addConstraint:[self constraintTarget:self.textView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10]];

    NSString *str = @"这是占位符,@kigou www.baidu.com zhoucan123@vip.qq.com 023-71443816";
    
    CGFloat height = [JSCoreTextView measureFrameHeightForText:str                                                      fontName:@"Helvetica"
                                                      fontSize:16.0
                                            constrainedToWidth:self.bounds.size.width                                                    paddingTop:0.0
                                                   paddingLeft:0.0];


    [self addConstraint:[self constraintTarget:self.textView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self.sourceView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-15]];

    NSLayoutConstraint *heightConstraint =[self constraintTarget:self.textView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height];
    
    [self addConstraint:heightConstraint];
    
    if (!self.constraintDict) {
        self.constraintDict = [[NSMutableDictionary alloc]init];
    }
    [self.constraintDict setObject:heightConstraint forKey:@"textViewHeightConstraint"];

    self.textView.text = str;
    self.textView.fontName = @"Helvetica";
    self.textView.fontSize = 16.0f;
    
    self.textView.backgroundColor = [UIColor clearColor];
    
    
    //缩略图
    
    _picUrlView = [[UIView alloc]init];
    [_picUrlView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.sourceView addSubview:_picUrlView];
    
    //左对齐
    [self.sourceView addConstraint:[self constraintTarget:self.picUrlView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
    
    
    [self.sourceView addConstraint:[self constraintTarget:self.picUrlView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:_textView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5]];

    
    [self addConstraint:[self constraintTarget:self.picUrlView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self.sourceView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-15]];
    
    NSLayoutConstraint *pic_heightConstraint =[self constraintTarget:self.picUrlView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:2];

    [self addConstraint:pic_heightConstraint];
    
    [self.constraintDict setObject:pic_heightConstraint forKey:@"picUrlViewHeightConstraint"];
    
    self.picUrlView.backgroundColor = [UIColor clearColor];
    
    
    
    
    
    ////转发内容容器

    self.retweetView = [[UIView alloc]init];

    [_retweetView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.sourceView addSubview:_retweetView];
    
    
    //左对齐
    [self.sourceView addConstraint:[self constraintTarget:self.retweetView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:_photoHeadImageView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
    
    
    [self.sourceView addConstraint:[self constraintTarget:_retweetView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:_picUrlView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5]];
    
    
    [self addConstraint:[self constraintTarget:_retweetView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self.sourceView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-15]];
    
    NSLayoutConstraint *retweet_heightConstraint =[self constraintTarget:self.retweetView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:2];
    
    [self addConstraint:retweet_heightConstraint];
    
    [self.constraintDict setObject:retweet_heightConstraint forKey:@"retweet_heightConstraint"];
    
    self.retweetView.backgroundColor = [UIColor clearColor];
    
    
    ////转发内容
    
    self.retweetTextView = [[JSTwitterCoreTextView alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
    [self.retweetTextView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.retweetView addSubview:self.retweetTextView];
    
    
    
    
    //左对齐
    [self.retweetView addConstraint:[self constraintTarget:self.retweetTextView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:self.retweetView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
    
    
    [self.retweetView addConstraint:[self constraintTarget:self.retweetTextView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:self.retweetView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5]];
    
    NSString *str1 = @"转发内容";
    
    
    
    [self.retweetView addConstraint:[self constraintTarget:self.retweetTextView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self.retweetView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-5]];
    
    NSLayoutConstraint *retweetTextHeightCons =[self constraintTarget:self.retweetTextView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:5];
    
    [self.retweetView addConstraint:retweetTextHeightCons];
    
    [self.constraintDict setObject:retweetTextHeightCons forKey:@"retweetTextHeightCons"];
    
    self.retweetTextView.text = str1;
    self.retweetTextView.fontName = @"Helvetica";
    self.retweetTextView.fontSize = 16.0f;
    
    self.retweetTextView.backgroundColor = [UIColor clearColor];
    self.retweetTextView.text=str1;
    
    
    
    //转发内容缩略图
    _retweetPicUrlView = [[UIView alloc]init];
    [self.retweetPicUrlView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.retweetView addSubview:self.retweetPicUrlView];
    self.retweetPicUrlView.backgroundColor = [UIColor clearColor];
    
    //左对齐
    [self.retweetView addConstraint:[self constraintTarget:self.retweetPicUrlView attribute:NSLayoutAttributeLeading relatedby:NSLayoutRelationEqual toItem:self.retweetView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
    
    
    [self.retweetView addConstraint:[self constraintTarget:self.retweetPicUrlView attribute:NSLayoutAttributeTop relatedby:NSLayoutRelationEqual toItem:self.retweetTextView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5]];
    
    
    
    
    [self.retweetView addConstraint:[self constraintTarget:self.retweetPicUrlView attribute:NSLayoutAttributeWidth relatedby:NSLayoutRelationEqual toItem:self.retweetView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-15]];
    
    NSLayoutConstraint *retweetPicCons =[self constraintTarget:self.retweetPicUrlView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:5];
    
    [self.retweetView addConstraint:retweetPicCons];
    
    [self.constraintDict setObject:retweetPicCons forKey:@"retweetPicCons"];
    
    
    
    

    
}



-(CGFloat)height:(NSMutableDictionary *)dic{
    
    

    
    NSString *text = [dic objectForKey:@"text"];

    CGFloat height1 = [self getTextViewHeight:text];
    self.height+=height1;
    return self.height;

}



-(void)setContent:(NSMutableDictionary *)dic{
    
    self.height = 70.0;

    
    //头像
    
    NSString *photoHeaderStr = [[dic objectForKey:@"user"]objectForKey:@"avatar_large"];
    //姓名
    NSString *nameStr = [[dic objectForKey:@"user"]objectForKey:@"screen_name"];
    
    //时间
    NSString *timeStr = [dic objectForKey:@"created_at"];
    timeStr = [self formatDaySinaTime:timeStr];
    //来源
    NSString *sourceStr= [dic objectForKey:@"source"];
    
    sourceStr = [sourceStr stringByReplacingOccurrencesOfString:@"</a>" withString:@""];
    sourceStr = [sourceStr substringFromIndex:[sourceStr rangeOfString:@">"].location+1];

    //内容
    NSString *text = [dic objectForKey:@"text"];
    
    NSArray *picUrlArray = [dic objectForKey:@"pic_urls"];
    
    //设置头像
//    [_photoHeadImageView setImageWithURL:[NSURL URLWithString:photoHeaderStr] placeholderImage:nil];
   
    
    [_photoHeadImageView setImageWithURL:[NSURL URLWithString:photoHeaderStr]  placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
    }];
    
//    self.height += CGRectGetHeight(_photoHeadImageView.bounds);
    
    
    
    //设置姓名
    _nameLabel.text = nameStr;
    
    
    
    //设置时间
    self.timeLabel.text = timeStr;
    
    //设置来源
    self.sourceLabel.text = sourceStr;
    
    //设置内容
    
    
    CGFloat height = [self getTextViewHeight:text];
    NSLayoutConstraint *constaint = [self.constraintDict objectForKey:@"textViewHeightConstraint"];
    
    [self removeConstraint:constaint];
    
    NSLayoutConstraint *heightConstraint =[self constraintTarget:self.textView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height];
    
    [self addConstraint:heightConstraint];
    [self.constraintDict setObject:heightConstraint forKey:@"textViewHeightConstraint"];

    self.textView.text = text;
    
    
    
    //如果有图片

    
    if ([picUrlArray count]!=0) {
        self.height+=[self updatePicViewConstraint:picUrlArray];
    }
    
    
    //如果有转发内容
    
    if ([dic objectForKey:@"retweeted_status"]) {
        
        NSString *retweetString = [[[dic objectForKey:@"retweeted_status"]objectForKey:@"user"]objectForKey:@"screen_name"];
        NSString *text =[[dic objectForKey:@"retweeted_status"]objectForKey:@"text"];
        retweetString = [NSString stringWithFormat:@"%@:%@",retweetString,text];
        
        CGFloat height =[self getTextViewHeight:retweetString];
        
        self.height+=height+50;
        
        //更新转发容器大小
        
        //retweet_heightConstraint
        
        NSLayoutConstraint *deleteCons = [self.constraintDict objectForKey:@"retweet_heightConstraint"];
        
        [self removeConstraint:deleteCons];
        
        NSLayoutConstraint *newCons =[self constraintTarget:self.retweetView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height+40];
        
        [self addConstraint:newCons];
        [self.constraintDict setObject:heightConstraint forKey:@"retweet_heightConstraint"];
        
        //更新转发高度
        
        
        
        NSLayoutConstraint *constaint = [self.constraintDict objectForKey:@"retweetTextHeightCons"];
        
        [self.retweetView removeConstraint:constaint];
        
        NSLayoutConstraint *heightConstraint =[self constraintTarget:self.retweetTextView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height+30];
        
        [self.retweetView addConstraint:heightConstraint];
        [self.constraintDict setObject:heightConstraint forKey:@"retweetTextHeightCons"];
        
        self.retweetTextView.text = retweetString;
        
        
        
        //如果有转发URL
        
        
        NSArray *retweetPicUrlArray =[[dic objectForKey:@"retweeted_status"]objectForKey:@"pic_urls"];
        
        if ([retweetPicUrlArray count]!=0) {
            
            CGFloat height = [self updateRetweetPicViewConstraint:retweetPicUrlArray];
            self.height+=height;
            
            
        }

        
        
    }
    
    
        
    
    
    
}

-(CGFloat)updateRetweetPicViewConstraint:(NSArray *)picUrlArrar{
    
    
    CGFloat height = 0.0;
    
    //几行
    int number = [picUrlArrar count]/3;
    
    //图片的高
    int imageHeight = 100;
    height = number *imageHeight+10;
    
    if (number==0) {
        height=110;
    }
    
    
    for (UIView *view  in self.retweetPicUrlView.subviews) {
        [view removeFromSuperview];
    }
    
    NSLayoutConstraint *picUrlConstraint = [_constraintDict objectForKey:@"retweetPicCons"];
    
    [self removeConstraint:picUrlConstraint];
    
    NSLayoutConstraint *newPicUrlCons = [self constraintTarget:self.picUrlView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height];
    [self.retweetView addConstraint:newPicUrlCons];
    
    [_constraintDict setObject:newPicUrlCons forKey:@"retweetPicCons"];
    
    int x = 0;
    for (int i = 0; i<[picUrlArrar count]; i++) {
        
        if (i%3==0) {
            x=0;
        }else{
            x+=imageHeight+3;
        }
        
        NSString *urlStr = [[picUrlArrar objectAtIndex:i]objectForKey:@"thumbnail_pic"];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, (i/3)*(imageHeight+3), imageHeight, imageHeight)];
        
        
        [imageView setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:nil];
        [self.retweetPicUrlView addSubview:imageView];
        
    }

    return height;
    
}




-(CGFloat) updatePicViewConstraint:(NSArray *)picUrlArrar{
    
    CGFloat height = 0.0;
    
    //几行
    int number = [picUrlArrar count]/3;
    
    //图片的高
    int imageHeight = 100;
    height = number *imageHeight+10;
    
    if (number==0) {
        height=110;
    }

    
    for (UIView *view  in self.picUrlView.subviews) {
        [view removeFromSuperview];
    }
    
    NSLayoutConstraint *picUrlConstraint = [_constraintDict objectForKey:@"picUrlViewHeightConstraint"];
    
    [self removeConstraint:picUrlConstraint];
    
    NSLayoutConstraint *newPicUrlCons = [self constraintTarget:self.picUrlView attribute:NSLayoutAttributeHeight relatedby:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:height];
    [self addConstraint:newPicUrlCons];
    
    [_constraintDict setObject:newPicUrlCons forKey:@"picUrlViewHeightConstraint"];
    
    int x = 0;
    for (int i = 0; i<[picUrlArrar count]; i++) {
        
        if (i%3==0) {
            x=0;
        }else{
            x+=imageHeight+3;
        }
        
        NSString *urlStr = [[picUrlArrar objectAtIndex:i]objectForKey:@"thumbnail_pic"];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, (i/3)*(imageHeight+3), imageHeight, imageHeight)];
        
        
        [imageView setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:nil];
        [self.picUrlView addSubview:imageView];
        
    }
    
    
    
    
    return height;
    
}


-(CGFloat )getTextViewHeight:(NSString *)text{
    
    return [JSCoreTextView measureFrameHeightForText:text                                                      fontName:@"Helvetica"
                                                      fontSize:16.0
                                            constrainedToWidth:self.bounds.size.width                                                    paddingTop:0.0
                                                   paddingLeft:0.0];
    
}


//美国时间，处理新浪
-(NSString*)formatDaySinaTime:(NSString*)createAt
{
    //Thu Dec 19 11:57:36 +0800 2013
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"EEE MMM d HH:mm:ss Z yyyy";
    formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
    formatter2.dateFormat = @"yyyy-MM-dd-HH:mm";
    return [formatter2 stringFromDate:[formatter dateFromString:createAt]];
}


@end
